/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Administrador				
 */
@Entity
@Table(name = "pharmacy")
@NamedQueries({
    @NamedQuery(name = "Pharmacy.findAll", query = "SELECT p FROM Pharmacy p"),
    @NamedQuery(name = "Pharmacy.findByPharmacyId", query = "SELECT p FROM Pharmacy p WHERE p.pharmacyId = :pharmacyId"),
    @NamedQuery(name = "Pharmacy.findByRegionId", query = "SELECT p FROM Pharmacy p WHERE p.locality.localityPK.regionId = :regionId"),
    @NamedQuery(name = "Pharmacy.findByRegionIdByActive", query = "SELECT p FROM Pharmacy p WHERE p.locality.localityPK.regionId = :regionId AND p.active = :active"),
    @NamedQuery(name = "Pharmacy.findByName", query = "SELECT p FROM Pharmacy p WHERE p.name = :name"),
    @NamedQuery(name = "Pharmacy.findBySocialReason", query = "SELECT p FROM Pharmacy p WHERE p.socialReason = :socialReason"),
    @NamedQuery(name = "Pharmacy.findByInitials", query = "SELECT p FROM Pharmacy p WHERE p.initials = :initials"),
    @NamedQuery(name = "Pharmacy.findByNit", query = "SELECT p FROM Pharmacy p WHERE p.nit = :nit"),
    @NamedQuery(name = "Pharmacy.findByAddress", query = "SELECT p FROM Pharmacy p WHERE p.address = :address"),
    @NamedQuery(name = "Pharmacy.findByEmail", query = "SELECT p FROM Pharmacy p WHERE p.email = :email"),
    @NamedQuery(name = "Pharmacy.findByEmail2", query = "SELECT p FROM Pharmacy p WHERE p.email2 = :email2"),
    @NamedQuery(name = "Pharmacy.findByPhone", query = "SELECT p FROM Pharmacy p WHERE p.phone = :phone"),
    @NamedQuery(name = "Pharmacy.findByPhone2", query = "SELECT p FROM Pharmacy p WHERE p.phone2 = :phone2"),
    @NamedQuery(name = "Pharmacy.findByFax", query = "SELECT p FROM Pharmacy p WHERE p.fax = :fax"),
    @NamedQuery(name = "Pharmacy.findByWebsite", query = "SELECT p FROM Pharmacy p WHERE p.website = :website"),
    @NamedQuery(name = "Pharmacy.findByMainImage", query = "SELECT p FROM Pharmacy p WHERE p.mainImage = :mainImage"),
    @NamedQuery(name = "Pharmacy.findByLogo", query = "SELECT p FROM Pharmacy p WHERE p.logo = :logo"),
    @NamedQuery(name = "Pharmacy.findByReportLogo", query = "SELECT p FROM Pharmacy p WHERE p.reportLogo = :reportLogo"),
    @NamedQuery(name = "Pharmacy.findByDateCreation", query = "SELECT p FROM Pharmacy p WHERE p.dateCreation = :dateCreation"),
    @NamedQuery(name = "Pharmacy.findByClient", query = "SELECT p FROM Pharmacy p WHERE p.client = :client"),
    @NamedQuery(name = "Pharmacy.findByPharmacyIdByActive", query = "SELECT p FROM Pharmacy p WHERE p.pharmacyId = :pharmacyId AND p.active = :active"),
    @NamedQuery(name = "Pharmacy.findByPhaPharmacyIdByActive", query = "SELECT p FROM Pharmacy p WHERE p.phapharmacyId.pharmacyId = :pharmacyId AND p.active = :active"),
    @NamedQuery(name = "Pharmacy.findByActive", query = "SELECT p FROM Pharmacy p WHERE p.active = :active")})
public class Pharmacy implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)										
    @Column(name = "pharmacyId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer pharmacyId;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "socialReason")
    private String socialReason;
    @Column(name = "initials")
    private String initials;
    @Column(name = "nit")
    private String nit;
    @Column(name = "address")
    private String address;
    @Column(name = "email")
    private String email;
    @Column(name = "email2")
    private String email2;
    @Column(name = "phone")
    private String phone;
    @Column(name = "phone2")
    private String phone2;
    @Column(name = "fax")
    private String fax;
    @Column(name = "website")
    private String website;
    @Column(name = "mainImage")
    private String mainImage;
    @Column(name = "logo")
    private String logo;
    @Column(name = "reportLogo")
    private String reportLogo;
    @Column(name = "dateCreation")
    @Temporal(TemporalType.DATE)
    private Date dateCreation;
    @Basic(optional = false)
    @Column(name = "client")
    private boolean client;
    @Column(name = "active")
    private Boolean active;
    @JoinColumns({
        @JoinColumn(name = "regionId", referencedColumnName = "regionId"),
        @JoinColumn(name = "localityId", referencedColumnName = "localityId")})
    @ManyToOne
    private Locality locality;
    @OneToMany(mappedBy = "phapharmacyId")
    private Collection<Pharmacy> pharmacyCollection;
    @JoinColumn(name = "Pha_pharmacyId", referencedColumnName = "pharmacyId")
    @ManyToOne
    private Pharmacy phapharmacyId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pharmacy")
    private Collection<Pharmacystock> pharmacystockCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pharmacyId")
    private Collection<Client> clientCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pharmacy")
    private Collection<Userpharmacy> userpharmacyCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pharmacy")
    private Collection<Pharmacyproduct> pharmacyproductCollection;
    @OneToMany(mappedBy = "pharmacyId")
    private Collection<Dosage> dosageCollection;
    @OneToMany(mappedBy = "pharmacyId")
    private Collection<Acquittance> acquittanceCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pharmacy")
    private Collection<Providerpharmacy> providerpharmacyCollection;

    public Pharmacy() {
    }

    public Pharmacy(Integer pharmacyId) {
        this.pharmacyId = pharmacyId;
    }

    public Pharmacy(Integer pharmacyId, String name, boolean client) {
        this.pharmacyId = pharmacyId;
        this.name = name;
        this.client = client;
    }

    public Integer getPharmacyId() {
        return pharmacyId;
    }

    public void setPharmacyId(Integer pharmacyId) {
        this.pharmacyId = pharmacyId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSocialReason() {
        return socialReason;
    }

    public void setSocialReason(String socialReason) {
        this.socialReason = socialReason;
    }

    public String getInitials() {
        return initials;
    }

    public void setInitials(String initials) {
        this.initials = initials;
    }

    public String getNit() {
        return nit;
    }

    public void setNit(String nit) {
        this.nit = nit;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getEmail2() {
        return email2;
    }

    public void setEmail2(String email2) {
        this.email2 = email2;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getPhone2() {
        return phone2;
    }

    public void setPhone2(String phone2) {
        this.phone2 = phone2;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public String getMainImage() {
        return mainImage;
    }

    public void setMainImage(String mainImage) {
        this.mainImage = mainImage;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public String getReportLogo() {
        return reportLogo;
    }

    public void setReportLogo(String reportLogo) {
        this.reportLogo = reportLogo;
    }

    public Date getDateCreation() {
        return dateCreation;
    }

    public void setDateCreation(Date dateCreation) {
        this.dateCreation = dateCreation;
    }

    public boolean getClient() {
        return client;
    }

    public void setClient(boolean client) {
        this.client = client;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public Locality getLocality() {
        return locality;
    }

    public void setLocality(Locality locality) {
        this.locality = locality;
    }

    public Collection<Pharmacy> getPharmacyCollection() {
        return pharmacyCollection;
    }

    public void setPharmacyCollection(Collection<Pharmacy> pharmacyCollection) {
        this.pharmacyCollection = pharmacyCollection;
    }

    public Pharmacy getPhapharmacyId() {
        return phapharmacyId;
    }

    public void setPhapharmacyId(Pharmacy phapharmacyId) {
        this.phapharmacyId = phapharmacyId;
    }

    public Collection<Pharmacystock> getPharmacystockCollection() {
        return pharmacystockCollection;
    }

    public void setPharmacystockCollection(Collection<Pharmacystock> pharmacystockCollection) {
        this.pharmacystockCollection = pharmacystockCollection;
    }

    public Collection<Client> getClientCollection() {
        return clientCollection;
    }

    public void setClientCollection(Collection<Client> clientCollection) {
        this.clientCollection = clientCollection;
    }

    public Collection<Userpharmacy> getUserpharmacyCollection() {
        return userpharmacyCollection;
    }

    public void setUserpharmacyCollection(Collection<Userpharmacy> userpharmacyCollection) {
        this.userpharmacyCollection = userpharmacyCollection;
    }

    public Collection<Pharmacyproduct> getPharmacyproductCollection() {
        return pharmacyproductCollection;
    }

    public void setPharmacyproductCollection(Collection<Pharmacyproduct> pharmacyproductCollection) {
        this.pharmacyproductCollection = pharmacyproductCollection;
    }

    public Collection<Dosage> getDosageCollection() {
        return dosageCollection;
    }

    public void setDosageCollection(Collection<Dosage> dosageCollection) {
        this.dosageCollection = dosageCollection;
    }

    public Collection<Acquittance> getAcquittanceCollection() {
        return acquittanceCollection;
    }

    public void setAcquittanceCollection(Collection<Acquittance> acquittanceCollection) {
        this.acquittanceCollection = acquittanceCollection;
    }

    public Collection<Providerpharmacy> getProviderpharmacyCollection() {
        return providerpharmacyCollection;
    }

    public void setProviderpharmacyCollection(Collection<Providerpharmacy> providerpharmacyCollection) {
        this.providerpharmacyCollection = providerpharmacyCollection;
    }
/*
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (pharmacyId != null ? pharmacyId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pharmacy)) {
            return false;
        }
        Pharmacy other = (Pharmacy) object;
        if ((this.pharmacyId == null && other.pharmacyId != null) || (this.pharmacyId != null && !this.pharmacyId.equals(other.pharmacyId))) {
            return false;
        }
        return true;
    }

    @Override*/
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Pharmacy[ pharmacyId=" + pharmacyId + " ]";
    }
    
}
